home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10406 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.5 KB

  1. Path: newshost.netinfo.com.au!usenet
  2. From: Alan Brain <aebrain@dynamite.com.au>
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 7 Mar 1996 08:27:36 GMT
  6. Organization: Netinfo Pty Ltd - Canberra Australia
  7. Message-ID: <4hm6lo$eln@fred.netinfo.com.au>
  8. References: <JSA.96Feb16135027@organon.com> <SPENCER.96Feb29102241@zorgon.ERA.COM> <4h5bptINN9oi@anvil.ugrad.cs.ubc.ca> <4hakfl$ogd@fred.netinfo.com.au> <4hf701INNdl7@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: dialup7.dynamite.com.au
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  14.  
  15. c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  16. >In article <4hakfl$ogd@fred.netinfo.com.au>,
  17. >Alan Brain  <aebrain@dynamite.com.au> wrote:
  18. > >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  19. > >
  20. > >
  21. > >>You are confusing the language specification with the implementation. The C
  22. > >>specification does not call for the ability randomly access memory. The only
  23. > >>way to legally manufacture pointers is by taking the addresses of named
  24. > >>objects, using the standard defined function malloc() or through pointer
  25. > >>arithmetic (adding an integral displacement to an existing pointer---an
  26. > >>operation which yields undefined results if you try to create a pointer outside
  27. > >>of an object). You aren't even legally allowed to subtract two pointers that
  28. > >>don't reference the same object, even if they have compatible types.
  29. > >
  30. Re: Soft Failures etc
  31.  
  32. >Ada compiled code will catch this? My ass.
  33.  
  34. Always? Nope. Sometimes? You bet. Usually? - Good question. Sometimes immediately, but 
  35. sometimes only after much useless computation - you give examples below that only a real 
  36. smart design would catch quickly:
  37.  
  38. >What if the parameter is altered in such a way that it stays within the index?
  39. >I suppose that you have a proof that this is safer and more reliable. After
  40. >all, if a mechanical arm is safer when it stays within certain physical limits,
  41. >surely an array index or pointer inside a digital computer is safer when it
  42. >stays within bounds, right?
  43. >
  44. >Keep dreaming in your imaginary world... 
  45.  
  46. ..and there are a million other failure modes that mere strong type checking will not 
  47. catch. Just as having good brakes will not stop the gas tank exploding. BUT... if (unlike 
  48. C) you don't have to write 2 lines of code to error-check 1 line that actually does 
  49. something, only 1 line for every 2-5 [have you ever seen really safe Ada code? nearly 
  50. every couple of statements have their own block and exception handlers!], the chances that 
  51. your error-correction will be relatively safe increases. The compiler does the work, 
  52. instead of (more) fallible mortals like myself. 
  53.  
  54. > >To give a concrete example, I - along with some very inexperienced programmers 
  55. > >- recently wrote a Threat Evaluation and Weapon Assignment segment. One which 
  56. > >would kill people if it didn't work exactly right, either by shooting at 
  57. > >friendlies, or allowing a missile through to hit the ship.
  58. >
  59. >That's why they assigned you to it, along with some very inexperienced
  60. >programmers!  Right on. Glad to know tax dollars are hard at work.
  61.  
  62. Yup, brought me out all the way from Australia to do it too. Just not for the US...
  63.  
  64. > >That's the key to success in my experience. Ada 83 code cannot be Bug-Free, 
  65. > >but it can be Bug-Resistant. C - except in certain ways, and with an 
  66. > >increase of up to 10 times the coding effort - can't.
  67. >
  68. >How do you know that? Most of the kinds of things you describe (e.g. range
  69. >checking) can be handled by a specialized compiler.
  70.  
  71. Correct. But then would it be standard C anymore? With a specialised compiler, you could 
  72. add strong typing, object inheritance, multitasking, generic structures, and while you're 
  73. at it, change the syntax to make it more readable hence understandable hence safer. You 
  74. could write a super-lint that not only did the tests but even inserted GOTOs ( ie raised an 
  75. exception) at the right places whenever an error could be detected. To make it readable, 
  76. you'd have to add a few reserved words, change the GOTOs to some other name, and so on.
  77. You could also write a validation suite that tested this super-lint that did all of the 
  78. above.
  79.  
  80. But I think using Ada 83 would be a little easier...OK, the code is NOT in Ada 83 (though 
  81. an Ada 83 compiler will compile it) It's in Safe C, and requires a specialised C compiler 
  82. with all the above features to munge it. Coincidentally, this specialised C compiler will 
  83. also handle Ada 83 code. But it's not Ada 83, it's safe C, just one more variant of the 
  84. totally-portable C family.  
  85.  
  86.